package com.bi.job;

import com.bi.service.RequestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: w
 * @Date: 2019/9/16 10:00
 * @Version 1.0
 */
@Slf4j
@Component
@EnableScheduling //开启定时任务注解
public class MyJob {
    @Resource
    private RequestService requestService;

    @Scheduled(cron = "0 0 1-23 * * ?") //从1点开始每小时执行一次
    public void addNum(){
        requestService.updateJob();
        log.info("从1点开始每小时执行一次");
    }

    @Scheduled(cron = "0 0 0 * * ? ") //每天0点执行更新
    public void reset(){
        log.info("每天0点执行更新");
    }

    @Scheduled(cron = "0 0/1 * * * ?") // 每分钟执行一次
    public void run(){
        log.info("每分钟执行一次");
    }
}
